package com.Iron.Advice;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class EnhanceMethod {

    @Pointcut("execution(* com.Iron.Service.Impl.*.*(..))")
    public void myPoincut(){

    }


    @Before("EnhanceMethod.myPoincut()")
    public void beforeAdvice() {
        System.out.println("开始了。。。");

    }
    @Around("EnhanceMethod.myPoincut()")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
        System.out.println("环绕前增强");
        Object proceed = proceedingJoinPoint.proceed();
        System.out.println("环绕前增强");
        return proceed;
    }


    @AfterReturning("EnhanceMethod.myPoincut()")
    public void afterRAdvice(){
        System.out.println("结束了。。。");
    }

    @AfterThrowing(pointcut = "EnhanceMethod.myPoincut()", throwing = "a")
    public void agterThrowingAdvice(Throwable a){
        System.out.println("抛出异常通知" + a);
    }

    @After("execution(* com.Iron.Service.Impl.*.*(..))")
    public void afterAdvice() {
        System.out.println("afterAdvice开始了。。。");

    }
}
